package com.zb.api.business.controller;

import com.zb.api.business.dto.PosWaresDto;
import com.zb.api.business.entity.UserEntity;
import com.zb.api.business.service.IPosMerchantService;
import com.zb.api.business.service.IPosWaresService;
import com.zb.api.common.econts.*;
import com.zb.api.common.models.CityVo;
import com.zb.api.common.models.ComboBoxVO;
import com.zb.api.utils.UserThreadLocal;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/select")
public class SelectController {

    @Resource
    private IPosMerchantService posMerchantService;

    @Resource
    private IPosWaresService posWaresService;

    /**
     * 商家类型枚举列
     * @return
     */
    @RequestMapping("getMerchantTypeList")
    public List<ComboBoxVO> getMerchantTypeList(){
        UserEntity userEntity = UserThreadLocal.get();
        List<ComboBoxVO> list = new ArrayList<>();
        //全部
        list.add(new ComboBoxVO("", "全部"));
        //遍历添加枚举
        for (MerchantTypeEnum typeEnum: MerchantTypeEnum.values()) {
            list.add(new ComboBoxVO(String.valueOf(typeEnum.getValue()), typeEnum.getDesc()));
        }
        return list;
    }

    /**
     * 城市县列表
     * @param cityVo
     * @return
     */
    @RequestMapping("getCityList")
    public List<ComboBoxVO> getCityList(@RequestBody CityVo cityVo){
        List<ComboBoxVO> list = posMerchantService.getCityList(cityVo);
        //全部
        return list;
    }

    /**
     * 居室列表
     * @return
     */
    @RequestMapping("getRoomEnumList")
    public List<ComboBoxVO> getRoomEnumList(){
        List<ComboBoxVO> list = new ArrayList<>();
        //全部
        list.add(new ComboBoxVO("", "全部"));
        //遍历添加枚举
        for (RoomEnum typeEnum: RoomEnum.values()) {
            list.add(new ComboBoxVO(String.valueOf(typeEnum.getValue()), typeEnum.getDesc()));
        }
        return list;
    }

    /**
     * 材料列表
     * @param posWaresDto
     * @return
     */
    @RequestMapping("getWaresList")
    public List<PosWaresDto> getWaresList(@RequestBody PosWaresDto posWaresDto){
        List<PosWaresDto> list = posWaresService.getWaresList(posWaresDto);
        return list;
    }

    /**
     * 厅室类型
     * @return
     */
    @RequestMapping("getHallRoomEnumList")
    public List<ComboBoxVO> getHallRoomEnumList(){
        List<ComboBoxVO> list = new ArrayList<>();
        list.add(new ComboBoxVO("", "全部"));
        for (HallRoomEnum typeEnum: HallRoomEnum.values()) {
            list.add(new ComboBoxVO(String.valueOf(typeEnum.getValue()), typeEnum.getDesc()));
        }
        return list;
    }

    /**
     * 方案类型
     * @return
     */
    @RequestMapping("getLabelEnumList")
    public List<ComboBoxVO> getLabelEnumList(){
        List<ComboBoxVO> list = new ArrayList<>();
        list.add(new ComboBoxVO("", "全部"));
        for (LabelEnum typeEnum: LabelEnum.values()) {
            list.add(new ComboBoxVO(String.valueOf(typeEnum.getValue()), typeEnum.getDesc()));
        }
        return list;
    }

    /**
     * 材料类型
     * @return
     */
    @RequestMapping("getWaresTypeEnumList")
    public List<ComboBoxVO> getWaresTypeEnumList(){
        List<ComboBoxVO> list = new ArrayList<>();
        list.add(new ComboBoxVO("", "全部"));
        for (WaresTypeEnum typeEnum: WaresTypeEnum.values()) {
            list.add(new ComboBoxVO(String.valueOf(typeEnum.getValue()), typeEnum.getDesc()));
        }
        return list;
    }


    /**
     * 方案主题
     * @return
     */
    @RequestMapping("getDecorationStyleEnumList")
    public List<ComboBoxVO> getDecorationStyleEnumList(){
        List<ComboBoxVO> list = new ArrayList<>();
        list.add(new ComboBoxVO("", "全部"));
        for (DecorationStyleEnum typeEnum: DecorationStyleEnum.values()) {
            list.add(new ComboBoxVO(String.valueOf(typeEnum.getValue()), typeEnum.getDesc()));
        }
        return list;
    }


}
